package com.model;

import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapSerializationEnvelope;

import android.R.bool;
import android.util.Log;

import com.exiassassin.librairies.game.Player;

public class PlayerImp extends Player implements KvmSerializable{

	private static final String NAMESPACE = "http://server.exiassassin.com";
	@Override
	public Player denounceKiller(Player player) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Player killPlayer(Player player) {
		// TODO Auto-generated method stub
		return null;
	}

	public Object getProperty(int arg0) {
		 switch (arg0){
		 case 1:
		 	return this.id;
		 case 2:
			return this.login;
		 case 3:
			return this.password;
		/* case 3:
			return picture;*/
		 case 0:
			return this.alive;
		/* case 5:
			return targetsList;
		 case 6:
			return coordinates;*/
		  }
		return null;
	}

	public int getPropertyCount() {
		return 4;
	}

	public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
		switch (arg0){
		  case 1:
		   arg2.type = int.class;
		   arg2.name = "id";
		   break;
		  case 2:
		   arg2.type = String.class;
		   arg2.name = "login";
		   break;
		  case 3:
		   arg2.type = String.class;
		   arg2.name = "password";
		   break;
		 /* case 3:
			   arg2.type = byte[].class;
			   arg2.name = "picture";
			   break;*/
		  case 0:
			   arg2.type = bool.class;
			   arg2.name = "alive";
			   break;
		 /* case 5:
			   arg2.type = Player[].class;
			   arg2.name = "targetsList";
			   break;
		  case 6:
			   arg2.type = Coordinates.class;
			   arg2.name = "coordinates";
			   break;*/
		  default:
		    break;
		  }
		
	}

	public void setProperty(int arg0, Object arg1) {
		switch(arg0){
		  case 1:
			  this.id = Integer.parseInt(arg1.toString());
		   break;
		  case 2:
			  this.login = arg1.toString();
			  break;
		  case 3:
			  this.password = arg1.toString();
		   break;
		/*  case 3:
			  picture = arg1.toString().getBytes();
			   
			   break;*/
		  case 0:
			  this.alive = Boolean.getBoolean(arg1.toString());
			   break;
		/*  case 5:
			  targetsList = (Player[])arg1;
			   break;
		  case 6:
			  coordinates = (Coordinates)arg1;
			   break;*/
		  }
	}
	 public void register(SoapSerializationEnvelope cm) {
         // TODO Auto-generated method stub
         Log.d("KVM","register");
          cm.addMapping(NAMESPACE, "PlayerImp", this.getClass());
     }

}
